Skip to content

Show token use against available context window on Chat message hover #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 69 commits into
base: main
Choose a base branch
from

Conversation

pierceboggan
Copy link
Contributor

@pierceboggan pierceboggan commented Aug 5, 2025

This PR adds support for visualizing current token usage against the model's available context window upon hover on a chat message:

image

This information was already present in the Copilot Chat debug log that is available with "Developer: Show Chat Debug View", but now is more visible and present directly within the chat message.

- Add tokenUsage field to IResultMetadata interface
- Update defaultIntentRequestHandler to store token info in metadata instead of inline markdown
- Enhance chatParticipantRequestHandler to display token usage in response details footer
- Token usage now appears alongside model info (e.g., 'GPT-4o • 0x • 2822/123901 tokens')
- Provides cleaner, structured approach using VS Code's ChatResult.metadata system
…y.tsx

- Revert conversationHistory.tsx to main branch version
- Keep only essential token usage functionality changes
- Removes unnecessary JSX formatting and null coalescing changes
@justschen justschen requested a review from lramos15 August 6, 2025 18:12
ulugbekna and others added 20 commits August 11, 2025 13:50
* language context providers: include mandatory fields that exist in latest language context providers API

* language context providers: convert additionalUris field for code snippets

* nes: respect additionalUris' copilot ignore

* nes: copilot-ignore the primary URI for code snippet

* Fixes #259794: Adapt source field when context provider is called from NES

---------

Co-authored-by: Dirk Baeumer <[email protected]>
* Fix thinking tool
#259934

* Update
* send thinking tokens progress to chat ui

* fix merge conflict:

* pass in id and metadata as well
* wip

* make it work

* error handling and retry on an invalid stateful marker

* Basic statefulMarker round-trip

* add createRequestBody on endpoints

* adopt createRequestBody in responses

* adopt generalized audience

Adopts microsoft/vscode#259273

* Slice messages array based on stateful marker data

* Send statefulMarker via LanguageModelDataPart

* Stateful marker container value is not JSON

* Properly ignore stateful marker when requested

* add setting for byok responses api, log view

* encode model with stateful marker

* Add setting to toggle responses api truncation vs our summarization

* Fix AutoChatEndpoint after merge

* vitest

* fixup

* Try enabling response for azure

---------

Co-authored-by: Connor Peet <[email protected]>
Co-authored-by: Logan Ramos <[email protected]>
* Add command to save current chat log as Markdown

This commit introduces a new command to save the currently opened chat log to a file in Markdown format. It includes a dialog for selecting the save location and handles errors during the save process.

| File                                      | Changes Made                                      |
|-------------------------------------------|--------------------------------------------------|
| src/extension/log/vscode-node/requestLogTree.ts | Added `saveCurrentMarkdownCommand` and its implementation |

* Enhance save current chat log command in requestLogTree

- Improved command to save the currently opened chat log by accepting a resource from menu invocation.
- Added fallback to the active editor's document if no resource is provided.
- Updated logic to read text from the virtual document URI explicitly before saving.

| File                                   | Changes Made                                      |
|----------------------------------------|--------------------------------------------------|
| src/extension/log/vscode-node/requestLogTree.ts | Enhanced command functionality and error handling |

* Refactor save dialog to use .md extension for Markdown files

- Changed default filename extension from .copilotmd to .md
- Updated save dialog filters to reflect the new .md extension

| File                                   | Changes                          |
|----------------------------------------|----------------------------------|
| src/extension/log/vscode-node/requestLogTree.ts | Updated filename and filters for save dialog |
* Update model selection checks

* nit: undo unrelated change
Refs microsoft/vscode#257379

I hypothesize that what's happening is the model tries to make an edit
with an invalid `oldString`. We then go to healing and the healing
process incorrectly causes the `newString` to no-op. This makes a
couple changes:

- Explicitly throw if oldString===newString, which we will get in telemetry
- Only do the `unescapeStringForGeminiBug` for Gemini, not Claude. Claude
  may not have this issue and is generally really good at self-correcting,
  I strongly suspect this code path is where things go awry.
* Enable enableRetryAfterFilteredResponse in Insiders

* Fix
* add length telemetry event with log message

* convert function arguments to length

* add completionId

* remove tokens

* add modelCallId

* fix modelCallId

* fix modelCallId

* move modelCallId from inside messages

* add type guard for 'tool_calls'

* add curly brackets

* remove duplicate noChoice

* use isOutput instead of guessing input/output

* fix usage issue

* change logging to debug mode

---------

Co-authored-by: Yevhen Mohylevskyy <[email protected]>
Co-authored-by: Yevhen Mohylevskyy <[email protected]>
* Delete knowledge bases

* Also delete SSO stuff
Which I am pretty confident is only used for knowledge bases
* Use lineNumberStyle for FileVariable

* vitest

* update test files with no baseline...

* Update baseline scores for toolCalling tests to reflect recent changes

* tests

* Update baseline

---------

Co-authored-by: Ulugbek Abdullaev <[email protected]>
* Remove some unused settings

* Another
isidorn and others added 27 commits August 11, 2025 13:50
* introuce networkError as a new type for CAPI errors

Fixes microsoft/vscode-internalbacklog/issues/5687

* fix errors
* rely more on observable document due to notebooks

* set debounceDelayMs to 0
* Fix backtick in search query breaking tool result codespan

* Fix
* separate added/removed lines

* leave undefined
Will need to fix these telemetry events for this API later
* Update getErrors (GetErrors / problems) tool

Update this tool so it can gather all errors.

* Updated model description so agent knows the tool can gather all errors
* Updated implementation such that if no URL is given, the tool returns all
errors.

* Update tool definition

Made the 'filePaths' argument optional, and updated description
to indicate how the argument should be used.

* Updates from review

* Made filePaths on IGetErrorParams optional, updated implementation of
invoke accordingly.
* Updated prepareInvoke to handle optional argument properly as
well.

* Tweaks

---------

Co-authored-by: Rob Lourens <[email protected]>
Took a long time, this started as a PR on the old vscode-copilot repo
* Add GPT-4.1 agent prompt and enhance tool capabilities

Implemented the GPT-4.1 specific agent prompt to improve multi-step task execution and problem-solving. Updated the DefaultAgentPrompt to conditionally render the new GPT41AgentPrompt based on the model family. Enhanced the tool capabilities detection function to streamline tool usage and added a new tool name for managing todo lists.

* Add setting for new prompt, tweaks

* Cleanup

---------

Co-authored-by: Rob Lourens <[email protected]>
* Initial plan

* Add NES requests filter implementation

Co-authored-by: roblourens <[email protected]>

* Refine NES request identification logic to avoid false positives

Co-authored-by: roblourens <[email protected]>

* Simplify

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: roblourens <[email protected]>
* Add some simple NES tests for alt format of notebooks

* Updates

* Updates
No model actually uses this config currently, but fix the instructions nevertheless

Closes microsoft/vscode#258888
* add CoreManageTodoList tool to packagejson tools for testing

* fix: update references from CoreTodoListTool to CoreManageTodoList
* Move terminal selection/command tools to core

Part of microsoft/vscode#259260

* Update baseline
@cmtzco
Copy link

cmtzco commented Aug 12, 2025

I'm a fan of the bar shown in the AI Usage Statistics. When hovered it could show the actual token usage and percentage.

image

@demiliani
Copy link

Why not showing something more clear, like the following:
IMG_1504

@cmtzco
Copy link

cmtzco commented Aug 12, 2025

Why not showing something more clear, like the following:

IMG_1504

While I agree that more information is generally better, not all users are advanced and prefer to see all that data. Instead, displaying it in a quick glance bar, such as the context usage percentage, would be more user-friendly and less overwhelming. Additionally, with the current amount of information already present in the window, adding more stats would only clutter the screen and reduce the available space for work or chat. Hovering over the relevant information would be a great way to display this data without taking up too much space on the window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.